Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle magic insertion marks when merging external features #1259

Merged
merged 2 commits into from
Feb 13, 2025
Merged

Conversation

cmyr
Copy link
Member

@cmyr cmyr commented Feb 13, 2025

This was about as straight-forward as I could've hoped for, I think, and gives us a modest crater boost.

assert!(item
.token_text()
.unwrap_or_default()
.contains("# Automatic Code"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love the assert, shouldn't we just check if it matches and go about our business if it doesn't? Is it imposible to write some other comment in this position for some reason?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We filter out comments as a rule, but we have an exception for comments containing this string. If this is ever not true, something is seriously broken.

assert!(
_name.is_none(),
"named lookup should be finished before insert marker"
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a bad state lets error. If it's not lets warn. Either way lets not assert.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking this is an invariant but actually this could occur in the wild if someone wrote,

feature test {
  lookup oops {
    # Automatic Code
  } oops;
} test;

that is, they put the comment inside a lookup block inside a feature.

Updated to just error in this case.

cmyr added 2 commits February 13, 2025 10:20
That is, we want to respect the '# Automatic Code' comments that are
used in glyphs sources.

Previously we would always just append any generated looups at the back
of the list; now if these markers are present we will insert the lookups
at that position.
@cmyr cmyr added this pull request to the merge queue Feb 13, 2025
Merged via the queue into main with commit 8019de2 Feb 13, 2025
11 checks passed
@cmyr cmyr deleted the insert-features branch February 13, 2025 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

handle "insert markers" when merging in feature code.
2 participants